#include "utils.h"

#include <iomanip>
#include <sstream>

std::string get_hex_string(const char *buf, unsigned int len)
{
    if (buf == nullptr || len < 0) {
        return "";
    }

    std::ostringstream oss;
    oss << std::setfill('0') << std::uppercase;
    for (int i = 0; i < len; i++) {
        oss << std::setw(2) << std::hex << static_cast<int>(buf[i] & 0xFF) << std::dec << ' ';
    }
    return oss.str();
}